<template>
  <div class="container">
    <el-dialog
      @checkOpen="checkOpenFn"
      title="题目审核"
      :visible.sync="dialogVisible"
      width="400px"
      @close="handleClose"
    >
      <el-form ref="form" :model="form" >
        <el-form-item prop="chkState">
          <el-radio v-model="form.chkState" :label="1">通过</el-radio>
          <el-radio v-model="form.chkState" :label="2">拒绝</el-radio>
        </el-form-item>
        <el-form-item prop="chkRemarks">
          <el-input v-model="form.chkRemarks" type="textarea"></el-input>
        </el-form-item>
        <el-form-item style="text-align: right">
          <el-button @click.native="handleClose">取 消</el-button>
          <el-button type="primary" @click="handleSubmit"
            >确 定</el-button
          >
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { choiceCheck } from '@/api/hmmm/questions.js'
export default {
  name: 'choice-check',
  props: {
    data: {
      default: () => {},
      type: Object

    }
  },
  data () {
    return {
      dialogVisible: false,
      form: {
        id: '',
        chkRemarks: '',
        chkState: 1
      }
    }
  },
  methods: {
    checkOpenFn (flag) {
      this.dialogVisible = flag
    },
    // 关闭对话框并重置
    handleClose () {
      this.dialogVisible = false
      this.form = {
        id: '',
        chkRemarks: '',
        chkState: 1
      }
    },
    // 提交审核
    async handleSubmit () {
      if (!this.form.chkRemarks) {
        return this.$message.warning('请输入审核意见!')
      }
      console.log(this.data, '...........****')
      this.form.id = this.data.id
      // console.log(this.form.id, '2222222.......')
      const res = await choiceCheck(this.form)
      console.log(res, '111111111122222222222')
      this.$message.success('审核成功!')
      this.dialogVisible = false
      this.$emit('submit-remark')
    }

  }
}
</script>

<style scoped lang="scss"></style>
